/*
 * Copyright (c) 2017 zhangcm. All Rights Reserved.
 */
package com.jnzc.ocr.serv.shop.helper;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.jnzc.ocr.common.utils.StringSubUtils;
import com.jnzc.ocr.serv.shop.entity.ShopCheck;
import com.jnzc.ocr.serv.shop.entity.ShopCheckDetail;
import org.apache.commons.lang3.StringUtils;

import java.text.MessageFormat;
import java.util.List;
import java.util.Set;

/**
 * @author zhangcm
 * @version 1.0, 2017/10/15
 */
public class ShopCheckHelper {

    private ShopCheckHelper(){}

    public static String getContent(List<ShopCheckDetail> detailList) {
        Set<String> result = Sets.newLinkedHashSet();
        for (ShopCheckDetail obj : detailList) {
            StringBuilder sb = new StringBuilder(obj.getProductName());
            if(StringUtils.isNotEmpty(obj.getSkuName())){
                sb.append("," + obj.getSkuName());
            }
            sb.append("(");
            if(obj.getChangeNum() > 0) {
                sb.append("+");
            }
            sb.append(obj.getChangeNum()).append(")");
            result.add(sb.toString());
        }
        return StringSubUtils.get(StringUtils.join(result, "、"), 2000, "...");
    }
}
